package cn.baiyang.rocketmq.spring.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 *
 * @author hongzhu
 * @version V1.0
 * @since 2023-07-24 18:11
 */
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RocketMQMessageListener {

    String ENDPOINTS_PLACEHOLDER = "${rocketmq-java.endpoints:}";
    String ACCESS_KEY_PLACEHOLDER = "${rocketmq-java.accesskey:}";
    String SECRET_KEY_PLACEHOLDER = "${rocketmq-java.secretkey:}";
    String ENABLE_SSL_PLACEHOLDER = "${rocketmq-java.enable-ssl:true}";
    String REQUEST_TIMEOUT_PLACEHOLDER = "${rocketmq-java.request-timeout:180}";

    /**
     * The property of "endpoints".
     * @return String
     */
    String endpoints() default ENDPOINTS_PLACEHOLDER;

    /**
     * The property of "accesskey".
     * @return String
     */
    String accessKey() default ACCESS_KEY_PLACEHOLDER;

    /**
     * The property of "secretkey".
     * @return String
     */
    String secretKey() default SECRET_KEY_PLACEHOLDER;

    /**
     * The property of "enableSsl".
     * @return String
     */
    String enableSsl() default ENABLE_SSL_PLACEHOLDER;

    /**
     * The property of "request-timeout".
     * @return String
     */
    String requestTimeout() default REQUEST_TIMEOUT_PLACEHOLDER;

    /**
     * <pre>
     * Consumers of the same role is required to have exactly same subscriptions and consumerGroup to correctly achieve
     * load balance. It's required and needs to be globally unique.
     * See <a href="https://rocketmq.apache.org/zh/docs/domainModel/07consumergroup">here</a> for further discussion.
     * </pre>
     * @return String
     */
    String consumerGroup();

    /**
     * Topic name.
     * @return String
     */
    String topic();

    /**
     * <pre>
     * Control how to selector message.
     * 不支持placeholder
     * </pre>
     * @see SelectorType
     * @return {@link cn.baiyang.rocketmq.spring.annotation.SelectorType}
     */
    SelectorType selectorType() default SelectorType.TAG;

    /**
     * Control which message can be select. Grammar please see {@link SelectorType#TAG} and {@link SelectorType#SQL92}
     * @return String
     */
    String selectorExpression() default "*";

    /**
     * <pre>
     * 客户端本地缓存的最大消息条数，默认为1024条
     * 不支持placeholder
     * </pre>
     * @return int
     */
    int maxCacheMessageCount() default  1024;

    /**
     * <pre>
     * 户端本地缓存的最大消息字节数，默认为64M
     * 不支持placeholder
     * </pre>
     * @return int
     */
    int maxCacheMessageSizeInBytes() default  64 * 1024 * 1024;

    /**
     * <pre>
     * 消费的线程数，默认为20个
     * 不支持placeholder
     * </pre>
     * @return int
     */
    int consumptionThreadCount() default  20;

    /**
     * <pre>
     * 消费者类型，默认为PushConsumer
     * 暂不支持Pull类型(官方API还没出来)
     * 不支持placeholder
     * </pre>
     * @return {@link cn.baiyang.rocketmq.spring.annotation.ConsumerType}
     */
    ConsumerType consumerType() default ConsumerType.PUSH;

    /**
     * The property of "instanceName".
     * @return String
     */
    String instanceName() default "DEFAULT";

}
